/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.japo.java.matisse.samples;

import java.awt.event.KeyEvent;
import org.japo.java.swing.events.GEABola;
import javax.swing.Timer;
import org.japo.java.swing.events.GEASupDer;

/**
 *
 * @author Jose A. Pacheco
 */
public class Pong extends javax.swing.JFrame {

    // Bola
    private Timer timerBola;
    private GEABola geaBola;
    private final int RETARDO_BOLA = 20;
    private final boolean DIR_HOR_BOLA_INI = true;      // Derecha
    private final boolean DIR_VER_BOLA_INI = false;     // Abajo
    private final int PASO_BOLA = 2;

    // Pala arriba
    private Timer timerArrDer;
    private Timer timerArrIzq;
    private GEASupDer geaArrDer;
    private GEASupDer geaArrIzq;
    private final int TECLA_ARR_DER = KeyEvent.VK_D;
    private final int TECLA_ARR_IZQ = KeyEvent.VK_A;

    // Pala abajo
    private Timer timerAbjDer;
    private Timer timerAbjIzq;
    private GEASupDer geaAbjDer;
    private GEASupDer geaAbjIzq;
    private final int TECLA_ABJ_IZQ = KeyEvent.VK_LEFT;
    private final int TECLA_ABJ_DER = KeyEvent.VK_RIGHT;

    // Ambas palas
    private final int RETARDO_PALA = 20;
    private final int PASO_PALA = 3;

    private final boolean[] teclaPulsada = new boolean[256];
    static int contador = 0;

    /**
     * Creates new form Pong
     */
    public Pong() {
        initComponents();
        iniciarPosterior();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlPista = new javax.swing.JPanel();
        lblPelota = new javax.swing.JLabel();
        lblPalaInf = new javax.swing.JLabel();
        lblPalaSup = new javax.swing.JLabel();
        pnlRed = new javax.swing.JPanel();
        lblPelota18 = new javax.swing.JLabel();
        lblPelota9 = new javax.swing.JLabel();
        lblPelota6 = new javax.swing.JLabel();
        lblPelota16 = new javax.swing.JLabel();
        lblPelota11 = new javax.swing.JLabel();
        lblPelota13 = new javax.swing.JLabel();
        lblPelota14 = new javax.swing.JLabel();
        lblPelota20 = new javax.swing.JLabel();
        lblPelota15 = new javax.swing.JLabel();
        lblPelota10 = new javax.swing.JLabel();
        lblPelota12 = new javax.swing.JLabel();
        lblPelota7 = new javax.swing.JLabel();
        lblPelota8 = new javax.swing.JLabel();
        lblPelota2 = new javax.swing.JLabel();
        lblPelota3 = new javax.swing.JLabel();
        lblPelota5 = new javax.swing.JLabel();
        lblPelota1 = new javax.swing.JLabel();
        lblPelota21 = new javax.swing.JLabel();
        lblPelota4 = new javax.swing.JLabel();
        lblMarcador1 = new javax.swing.JLabel();
        lblMarcador2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMaximumSize(new java.awt.Dimension(400, 600));
        setMinimumSize(new java.awt.Dimension(400, 600));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                formKeyReleased(evt);
            }
        });

        pnlPista.setBackground(java.awt.Color.black);
        pnlPista.setForeground(java.awt.Color.white);

        lblPelota.setBackground(java.awt.Color.white);
        lblPelota.setDoubleBuffered(true);
        lblPelota.setFocusable(false);
        lblPelota.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota.setOpaque(true);
        lblPelota.setPreferredSize(new java.awt.Dimension(20, 20));

        lblPalaInf.setBackground(java.awt.Color.white);
        lblPalaInf.setDoubleBuffered(true);
        lblPalaInf.setMaximumSize(new java.awt.Dimension(60, 20));
        lblPalaInf.setMinimumSize(new java.awt.Dimension(60, 20));
        lblPalaInf.setOpaque(true);
        lblPalaInf.setPreferredSize(new java.awt.Dimension(60, 20));

        lblPalaSup.setBackground(java.awt.Color.white);
        lblPalaSup.setDoubleBuffered(true);
        lblPalaSup.setMaximumSize(new java.awt.Dimension(60, 20));
        lblPalaSup.setMinimumSize(new java.awt.Dimension(60, 20));
        lblPalaSup.setOpaque(true);
        lblPalaSup.setPreferredSize(new java.awt.Dimension(60, 20));

        pnlRed.setBackground(java.awt.Color.white);
        pnlRed.setMaximumSize(new java.awt.Dimension(400, 20));
        pnlRed.setMinimumSize(new java.awt.Dimension(400, 20));
        pnlRed.setOpaque(false);
        pnlRed.setPreferredSize(new java.awt.Dimension(400, 20));
        pnlRed.setLayout(new java.awt.GridLayout(1, 20));

        lblPelota18.setBackground(java.awt.Color.black);
        lblPelota18.setDoubleBuffered(true);
        lblPelota18.setFocusable(false);
        lblPelota18.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota18.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota18.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota18);

        lblPelota9.setBackground(java.awt.Color.white);
        lblPelota9.setDoubleBuffered(true);
        lblPelota9.setFocusable(false);
        lblPelota9.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota9.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota9.setOpaque(true);
        lblPelota9.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota9);

        lblPelota6.setBackground(java.awt.Color.black);
        lblPelota6.setDoubleBuffered(true);
        lblPelota6.setFocusable(false);
        lblPelota6.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota6.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota6.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota6);

        lblPelota16.setBackground(java.awt.Color.white);
        lblPelota16.setDoubleBuffered(true);
        lblPelota16.setFocusable(false);
        lblPelota16.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota16.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota16.setOpaque(true);
        lblPelota16.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota16);

        lblPelota11.setBackground(java.awt.Color.black);
        lblPelota11.setDoubleBuffered(true);
        lblPelota11.setFocusable(false);
        lblPelota11.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota11.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota11.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota11);

        lblPelota13.setBackground(java.awt.Color.white);
        lblPelota13.setDoubleBuffered(true);
        lblPelota13.setFocusable(false);
        lblPelota13.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota13.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota13.setOpaque(true);
        lblPelota13.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota13);

        lblPelota14.setBackground(java.awt.Color.black);
        lblPelota14.setDoubleBuffered(true);
        lblPelota14.setFocusable(false);
        lblPelota14.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota14.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota14.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota14);

        lblPelota20.setBackground(java.awt.Color.white);
        lblPelota20.setDoubleBuffered(true);
        lblPelota20.setFocusable(false);
        lblPelota20.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota20.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota20.setOpaque(true);
        lblPelota20.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota20);

        lblPelota15.setBackground(java.awt.Color.black);
        lblPelota15.setDoubleBuffered(true);
        lblPelota15.setFocusable(false);
        lblPelota15.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota15.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota15.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota15);

        lblPelota10.setBackground(java.awt.Color.white);
        lblPelota10.setDoubleBuffered(true);
        lblPelota10.setFocusable(false);
        lblPelota10.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota10.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota10.setOpaque(true);
        lblPelota10.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota10);

        lblPelota12.setBackground(java.awt.Color.black);
        lblPelota12.setDoubleBuffered(true);
        lblPelota12.setFocusable(false);
        lblPelota12.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota12.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota12.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota12);

        lblPelota7.setBackground(java.awt.Color.white);
        lblPelota7.setDoubleBuffered(true);
        lblPelota7.setFocusable(false);
        lblPelota7.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota7.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota7.setOpaque(true);
        lblPelota7.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota7);

        lblPelota8.setBackground(java.awt.Color.black);
        lblPelota8.setDoubleBuffered(true);
        lblPelota8.setFocusable(false);
        lblPelota8.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota8.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota8.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota8);

        lblPelota2.setBackground(java.awt.Color.white);
        lblPelota2.setDoubleBuffered(true);
        lblPelota2.setFocusable(false);
        lblPelota2.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota2.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota2.setOpaque(true);
        lblPelota2.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota2);

        lblPelota3.setBackground(java.awt.Color.black);
        lblPelota3.setDoubleBuffered(true);
        lblPelota3.setFocusable(false);
        lblPelota3.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota3.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota3.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota3);

        lblPelota5.setBackground(java.awt.Color.white);
        lblPelota5.setDoubleBuffered(true);
        lblPelota5.setFocusable(false);
        lblPelota5.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota5.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota5.setOpaque(true);
        lblPelota5.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota5);

        lblPelota1.setBackground(java.awt.Color.black);
        lblPelota1.setDoubleBuffered(true);
        lblPelota1.setFocusable(false);
        lblPelota1.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota1.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota1.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota1);

        lblPelota21.setBackground(java.awt.Color.white);
        lblPelota21.setDoubleBuffered(true);
        lblPelota21.setFocusable(false);
        lblPelota21.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota21.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota21.setOpaque(true);
        lblPelota21.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota21);

        lblPelota4.setBackground(java.awt.Color.black);
        lblPelota4.setDoubleBuffered(true);
        lblPelota4.setFocusable(false);
        lblPelota4.setMaximumSize(new java.awt.Dimension(20, 20));
        lblPelota4.setMinimumSize(new java.awt.Dimension(20, 20));
        lblPelota4.setPreferredSize(new java.awt.Dimension(20, 20));
        pnlRed.add(lblPelota4);

        lblMarcador1.setBackground(java.awt.Color.black);
        lblMarcador1.setFont(new java.awt.Font("West_england", 0, 80)); // NOI18N
        lblMarcador1.setForeground(java.awt.Color.white);
        lblMarcador1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblMarcador1.setText("00");

        lblMarcador2.setBackground(java.awt.Color.black);
        lblMarcador2.setFont(new java.awt.Font("West_england", 0, 80)); // NOI18N
        lblMarcador2.setForeground(java.awt.Color.white);
        lblMarcador2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblMarcador2.setText("00");

        javax.swing.GroupLayout pnlPistaLayout = new javax.swing.GroupLayout(pnlPista);
        pnlPista.setLayout(pnlPistaLayout);
        pnlPistaLayout.setHorizontalGroup(
            pnlPistaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnlRed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlPistaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlPistaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlPistaLayout.createSequentialGroup()
                        .addComponent(lblPalaInf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlPistaLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(pnlPistaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblPalaSup, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblMarcador2, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(lblMarcador1, javax.swing.GroupLayout.Alignment.TRAILING))))
                .addContainerGap())
            .addGroup(pnlPistaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(pnlPistaLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(lblPelota, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        pnlPistaLayout.setVerticalGroup(
            pnlPistaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPistaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblPalaSup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(164, 164, 164)
                .addComponent(lblMarcador1, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnlRed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(lblMarcador2, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 157, Short.MAX_VALUE)
                .addComponent(lblPalaInf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(pnlPistaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(pnlPistaLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(lblPelota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnlPista, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnlPista, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        setSize(new java.awt.Dimension(416, 639));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        // Tamaño de la pelota
        int wBall = lblPelota.getWidth();
        int hBall = lblPelota.getHeight();

        // Tamaño de la pantalla
        int wCourt = pnlPista.getWidth();
        int hCourt = pnlPista.getHeight();

        // Posición de inicio de la pelota
        int xBall = (wCourt - wBall) / 2;
        int yBall = (hCourt - hBall) / 2;

        // Asigna la posición de la pelota
        lblPelota.setLocation(xBall, yBall);

        // Posicion inicio de la pala inferior
        int xPalInf = 20;
        int yPalInf = hCourt - 100;

        // Asigna la posición a la pala inicial
//        lblPalaInf.setLocation(xPalInf, yPalInf);

        // Inicia el movimiento de la bola
        timerBola.start();
    }//GEN-LAST:event_formWindowActivated

    private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed
        // Obtiene el código de la tecla
        int codigoTecla = evt.getKeyCode();

        // Activa el semáforo de la tecla pulsada
        teclaPulsada[codigoTecla] = true;

        // Gestiona la tecla
        if (codigoTecla == TECLA_ABJ_DER) {
            // Parar el temporizador de la otra tecla esté como esté
            timerAbjIzq.stop();

            // Activa el temporizador de la tecla pulsada
            if (!timerAbjDer.isRunning()) {    // Pala parada
                timerAbjDer.start();
            }
        } else if (codigoTecla == TECLA_ABJ_IZQ) {
            // Parar el temporizador de la otra tecla esté como esté
            timerAbjDer.stop();

            // Activa el temporizador de la tecla pulsada
            if (!timerAbjIzq.isRunning()) {    // Pala parada
                timerAbjIzq.start();
            }
        } else if (codigoTecla == TECLA_ARR_DER) {
            // Parar el temporizador de la otra tecla esté como esté
            timerArrIzq.stop();

            // Activa el temporizador de la tecla pulsada
            if (!timerArrDer.isRunning()) {    // Pala parada
                timerArrDer.start();
            }
        } else if (codigoTecla == TECLA_ARR_IZQ) {
            // Parar el temporizador de la otra tecla esté como esté
            timerArrDer.stop();

            // Activa el temporizador de la tecla pulsada
            if (!timerArrIzq.isRunning()) {    // Pala parada
                timerArrIzq.start();
            }
        }
    }//GEN-LAST:event_formKeyPressed

    private void formKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyReleased
        // Obtiene el código de la tecla
        int codigoTecla = evt.getKeyCode();

        // Desactiva el semáforo de la tecla pulsada
        teclaPulsada[codigoTecla] = false;

        // Gestiona la tecla
        if (codigoTecla == TECLA_ABJ_DER) {
            // Para el temporizador de la tecla
            timerAbjDer.stop();

            // Si la otra tecla está activa activa su temporizador
            if (teclaPulsada[TECLA_ABJ_IZQ]) {
                timerAbjIzq.start();
            }
        } else if (codigoTecla == TECLA_ABJ_IZQ) {
            // Para el temporizador de la tecla
            timerAbjIzq.stop();

            // Si la otra tecla está activa activa su temporizador
            if (teclaPulsada[TECLA_ABJ_DER]) {
                timerAbjDer.start();
            }
        } else if (codigoTecla == TECLA_ARR_DER) {
            // Para el temporizador de la tecla
            timerArrDer.stop();

            // Si la otra tecla está activa activa su temporizador
            if (teclaPulsada[TECLA_ARR_IZQ]) {
                timerArrIzq.start();
            }
        } else if (codigoTecla == TECLA_ARR_IZQ) {
            // Para el temporizador de la tecla
            timerArrIzq.stop();

            // Si la otra tecla está activa activa su temporizador
            if (teclaPulsada[TECLA_ARR_DER]) {
                timerArrDer.start();
            }
        }
    }//GEN-LAST:event_formKeyReleased

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Pong.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Pong.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Pong.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Pong.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            @Override
//            public void run() {
//                new Pong().setVisible(true);
//            }
//        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lblMarcador1;
    private javax.swing.JLabel lblMarcador2;
    private javax.swing.JLabel lblPalaInf;
    private javax.swing.JLabel lblPalaSup;
    private javax.swing.JLabel lblPelota;
    private javax.swing.JLabel lblPelota1;
    private javax.swing.JLabel lblPelota10;
    private javax.swing.JLabel lblPelota11;
    private javax.swing.JLabel lblPelota12;
    private javax.swing.JLabel lblPelota13;
    private javax.swing.JLabel lblPelota14;
    private javax.swing.JLabel lblPelota15;
    private javax.swing.JLabel lblPelota16;
    private javax.swing.JLabel lblPelota18;
    private javax.swing.JLabel lblPelota2;
    private javax.swing.JLabel lblPelota20;
    private javax.swing.JLabel lblPelota21;
    private javax.swing.JLabel lblPelota3;
    private javax.swing.JLabel lblPelota4;
    private javax.swing.JLabel lblPelota5;
    private javax.swing.JLabel lblPelota6;
    private javax.swing.JLabel lblPelota7;
    private javax.swing.JLabel lblPelota8;
    private javax.swing.JLabel lblPelota9;
    private javax.swing.JPanel pnlPista;
    private javax.swing.JPanel pnlRed;
    // End of variables declaration//GEN-END:variables

    private void iniciarPosterior() {
        // Movimiento de la pelota
//        geaBola = new GEATimerBola(pnlPista, lblPelota, DIR_HOR_BOLA_INI, DIR_VER_BOLA_INI, PASO_BOLA);
//        timerBola = new Timer(RETARDO_BOLA, geaBola);

        // Pala arriba derecha
//        timerArrDer = new Timer(RETARDO_PALA, null);
//        geaArrDer = new GEATimerPalaSupDer(pnlPista, lblPalaSup, PASO_PALA, timerArrDer);
//        geaArrDer.setDirHorOK(true);
//        timerArrDer.addActionListener(geaArrDer);

        // Pala arriba izquierda
//        timerArrIzq = new Timer(RETARDO_PALA, null);
//        geaArrIzq = new GEATimerPalaSupDer(pnlPista, lblPalaSup, PASO_PALA, timerArrIzq);
//        geaArrIzq.setDirHorOK(false);
//        timerArrIzq.addActionListener(geaArrIzq);

        // Pala abajo derecha
//        timerAbjDer = new Timer(RETARDO_PALA, null);
//        geaAbjDer = new GEATimerPalaSupDer(pnlPista, lblPalaInf, PASO_PALA, timerAbjDer);
//        geaAbjDer.setDirHorOK(true);
//        timerAbjDer.addActionListener(geaAbjDer);

        // Pala abajo izquierda
//        timerAbjIzq = new Timer(RETARDO_PALA, null);
//        geaAbjIzq = new GEATimerPalaSupDer(pnlPista, lblPalaInf, PASO_PALA, timerAbjIzq);
//        geaAbjIzq.setDirHorOK(false);
//        timerAbjIzq.addActionListener(geaAbjIzq);
    }
}
